package com.itheima.leetcode.od.c.logicalsimulation;

import java.util.Arrays;
import java.util.Scanner;

/**
 * <h3>灰度图存储</h3>
 */
public class GrayscaleImageStorage {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int[] nums1 = Arrays.stream(in.nextLine().split(" "))
                .mapToInt(Integer::parseInt)
                .toArray();
        int[] nums2 = Arrays.stream(in.nextLine().split(" "))
                .mapToInt(Integer::parseInt)
                .toArray();

        int target_position = nums2[0] * nums1[1] + nums2[1] + 1; // 二维转一维
        int total_sum = 0;
        int i = 3;
        while (i < nums1.length) {
            if (total_sum + nums1[i] <= target_position) {
                total_sum += nums1[i];

            } else {
                System.out.println(nums1[i - 1]);
                break;
            }
            i += 2;
        }
    }
}